package com.gitee.wsl.unit.volume

import com.gitee.wsl.unit.BaseUnit
import com.gitee.wsl.unit.UnitType

sealed interface VolumeUnitType: UnitType<Double> {
    object M_3: VolumeUnitType {
        override val baseUnit: Double = 1.0
    }
    object CM_3: VolumeUnitType {
        override val baseUnit: Double =  M_3.baseUnit *1.0E-6
    }
    object DM_3: VolumeUnitType {
        override val baseUnit: Double = M_3.baseUnit *0.001
    }
    object DAM_3: VolumeUnitType {
        override val baseUnit: Double = DM_3.baseUnit *0.001
    }
    object MM_3: VolumeUnitType {
        override val baseUnit: Double = M_3.baseUnit *0.001
    }

    object KM_3: VolumeUnitType {
        override val baseUnit: Double = M_3.baseUnit *1000000000.0
    }

    //桶
    object 桶: VolumeUnitType {
        override val baseUnit: Double = M_3.baseUnit *0.15898729492
    }

    //升
    object DL: VolumeUnitType {
        override val baseUnit: Double = M_3.baseUnit *0.001
    }
    //厘升
    object CL: VolumeUnitType {
        override val baseUnit: Double = DL.baseUnit *0.1
    }
    //毫升
    object ML: VolumeUnitType {
        override val baseUnit: Double = CL.baseUnit *0.1
    }
    //微升
    object HL: VolumeUnitType {
        override val baseUnit: Double = ML.baseUnit *0.001
    }

    /*object KL:VolumeUnitType {
        override val baseUnit: Double = 1.0
    }*/

    //加伦
    object GAL_USL: VolumeUnitType {
        override val baseUnit: Double = M_3.baseUnit *0.003785411783
    }
    /*object GAL_UK:VolumeUnitType {
        override val baseUnit: Double = 1.0
    }
    //流体
    object FL_OZ_US:VolumeUnitType {
        override val baseUnit: Double = 1.0
    }
    object FL_OZ_UK:VolumeUnitType {
        override val baseUnit: Double = 1.0
    }*/

    /**
     * 中国古代
    1石（dàn） = 10斗（dǒu）
    1斛（hú） = 本为10斗，后来改为5斗
    1斗（dǒu） = 10升
    1龠(yuè) = 0.5合（gě）
    1升 = 10合（gě）
     */
    object 石: VolumeUnitType {
        override val baseUnit: Double = 斗.baseUnit *10
    }
    object 斛: VolumeUnitType {
        override val baseUnit: Double = 斗.baseUnit *5
    }
    object 斗: VolumeUnitType {
        override val baseUnit: Double = DL.baseUnit *10
    }

}


sealed class VolumeUnit( value:Double, type: VolumeUnitType): BaseUnit<Double, VolumeUnitType>(value, type) {
    override fun toBase(): Double {
        return value*type.baseUnit
    }
}
